package com.yanqu.road.server.manager.activity.hsisland;

import com.yanqu.road.dao.impl.activity.hsisland.HsIslandUnionDataDaoImpl;
import com.yanqu.road.dao.impl.activity.hsisland.HsIslandUserDataDaoImpl;
import com.yanqu.road.entity.activity.hsisland.HsIslandPosition;
import com.yanqu.road.entity.activity.hsisland.HsIslandUnionLog;
import com.yanqu.road.entity.activity.hsisland.HsIslandVarianceData;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandBoatConfig;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandConfig;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandEventConfig;
import com.yanqu.road.entity.activity.hsisland.config.HsIslandIslandConfig;
import com.yanqu.road.entity.activity.hsisland.data.*;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandEventIdEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandLatticeTypeEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandMarqueeTypeEnum;
import com.yanqu.road.entity.activity.hsisland.enums.HsIslandUnionLogTypeEnum;
import com.yanqu.road.entity.activity.peakstronghold.CrossPeakStrongholdUnionData;
import com.yanqu.road.entity.activity.sonhai.data.SonHaiBattleLog;
import com.yanqu.road.entity.enums.eGamePlayerEventType;
import com.yanqu.road.entity.log.cross.hsisland.LogCrossHsIslandDonate;
import com.yanqu.road.entity.log.cross.hsisland.LogCrossHsIslandFloorUnlock;
import com.yanqu.road.entity.task.args.UnionRiseRankArgs;
import com.yanqu.road.entity.union.UnionBaseInfo;
import com.yanqu.road.entity.union.activitygroup.UnionActivityGroup;
import com.yanqu.road.entity.union.activitygroup.UnionActivityGroupUnion;
import com.yanqu.road.entity.union.activitygroup.UnionActivityGroupUser;
import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.hsisland.pb.CrossHsIslandActivityPb;
import com.yanqu.road.server.manager.log.CrossAutoLogMgr;
import com.yanqu.road.server.manager.union.activitygroup.Cross2UnionActivityGroupMgr;
import com.yanqu.road.server.manager.yrank.CrossYRankMgr;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.FixSizeLinkedList;
import com.yanqu.road.utils.ListHelper;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.utils.date.DateHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.mina.util.ConcurrentHashSet;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;

public class CrossHsIslandUnion {

    /**
     * 商会锁
     */
    private ReentrantLock lock = new ReentrantLock();

    /**
     * logger
     */
    private static Logger logger = LogManager.getLogger(CrossHsIslandUnion.class.getName());

    /**
     * 商会数据
     */
    private HsIslandUnionData unionData;

    /**
     * 海域map
     */
    private Map<Integer, CrossHsIslandFloor> floorMap;

    /**
     * 商会玩家MAP
     */
    private Map<Long, CrossHsIslandUser> userMap;

    /**
     * 商会日志
     */
    private FixSizeLinkedList<HsIslandUnionLog> unionLogList;

    /**
     * 构造方法
     * @param unionData
     * @param floorMap
     */
    public CrossHsIslandUnion(HsIslandUnionData unionData, Map<Integer, CrossHsIslandFloor> floorMap, Map<Long, CrossHsIslandUser> userMap, int logLimit) {
        this.unionData = unionData;
        this.floorMap = floorMap;
        this.userMap = userMap;
        this.unionLogList = new FixSizeLinkedList<>(logLimit);
    }

    /**
     * 数据存储
     */
    public void save() {
        //商会数据存储
        HsIslandUnionDataDaoImpl userDataDao = new HsIslandUnionDataDaoImpl();
        if (this.unionData.isInsertOption()) {
            userDataDao.add(this.unionData);
        } else if (this.unionData.isUpdateOption()) {
            userDataDao.update(this.unionData);
        }
        //海域数据存储
        for (CrossHsIslandFloor floor : this.floorMap.values()) {
            floor.save();
        }
    }

    /**
     * 获取配置
     * @return
     */
    public HsIslandConfig getConfig() {
        return CrossHsIslandActivityMgr.getConfig(this.unionData.getActivityId(), this.unionData.getGroupId());
    }

    /**
     * 获取锁
     * @return
     */
    public ReentrantLock getLock() {
        return lock;
    }

    /**
     * 获取商会数据
     * @return
     */
    public HsIslandUnionData getUnionData() {
        return this.unionData;
    }

    /**
     * 获取玩家MAP
     * @return
     */
    public Map<Long, CrossHsIslandUser> getUserMap() {
        return userMap;
    }

    /**
     * 注入玩家
     * @param user
     */
    public void putUser(CrossHsIslandUser user) {
        this.userMap.put(user.getUserData().getUserId(), user);
    }

    /**
     * 创建海域
     * @return
     */
    public synchronized CrossHsIslandFloor createFloor() throws BusinessException {
        int floorId = this.unionData.getMaxFloorId();
        CrossHsIslandFloor floor = this.floorMap.get(floorId);
        if (floor == null) {
            //根据权重随出3个岛ID
            List<Integer> islandIdList = this.getConfig().randomIslandIdList();
            //随机出宝箱的岛屿ID
            Integer boxIslandId = RandomHelper.getRandomElement(islandIdList);
            if (boxIslandId == null) {
                throw new BusinessException(GameErrorCode.E_HS_ISLAND_CREATE_FLOOR_ERROR);
            }
            //创建海域宝箱
            Map<String, HsIslandBoxData> boxDataMap = this.createBoxMap(boxIslandId);
            if (boxDataMap.isEmpty()) {
                logger.error("海神岛-创建海域-创建海域宝箱失败：{}, {}", floorId, boxIslandId);
            }
            //创建3个岛屿
            Map<Integer, CrossHsIslandIsland> islandMap = this.createIslandMap(floorId, islandIdList, boxIslandId, boxDataMap);
            if (islandMap == null || islandMap.size() != 3) {
                throw new BusinessException(GameErrorCode.E_HS_ISLAND_CREATE_FLOOR_ERROR);
            }
            //海域玩家MAP
            Map<Long, CrossHsIslandUser> userMap = new ConcurrentHashMap<>();
            //海域数据
            HsIslandFloorData floorData = new HsIslandFloorData(
                    this.unionData.getActivityId(),
                    this.unionData.getGroupId(),
                    this.unionData.getUnionId(),
                    floorId,
                    boxIslandId,
                    boxDataMap
            );
            floor = new CrossHsIslandFloor(floorData, islandMap, userMap);
            this.floorMap.put(floorId, floor);
        }
        return floor;
    }

    /**
     * 随机出宝箱
     * @param boxIslandId
     * @return
     * @throws BusinessException
     */
    private Map<String, HsIslandBoxData> createBoxMap(int boxIslandId) throws BusinessException {
        //获取岛屿
        HsIslandIslandConfig islandConfig = this.getConfig().getIslandConfig(boxIslandId);
        if (islandConfig == null) {
            throw new BusinessException(GameErrorCode.E_HS_ISLAND_ISLAND_NOT_FOUND);
        }
        //创建海域宝箱
        HsIslandEventConfig boxEventConfig = this.getConfig().getEventConfig(HsIslandEventIdEnum.EVENT_BOX.getType());
        if (boxEventConfig == null) {
            throw new BusinessException(GameErrorCode.E_HS_ISLAND_BOX_EVENT_CONFIG_NOT_FOUND);
        }
        return islandConfig.createBoxMap(boxEventConfig.getXNum(), boxEventConfig.getYNum(), this.getConfig().getBoxConfigMap());
    }

    /**
     * 创建岛MAP
     * @param floorId 海域ID
     * @param islandIdList 3个岛的ID
     * @param boxIslandId 宝箱的岛ID
     * @param boxDataMap 宝箱的MAP
     * @return
     */
    public synchronized Map<Integer, CrossHsIslandIsland> createIslandMap(int floorId, List<Integer> islandIdList, int boxIslandId, Map<String, HsIslandBoxData> boxDataMap) {
        Map<Integer, CrossHsIslandIsland> islandMap = new LinkedHashMap<>(3);
        for (int islandId : islandIdList) {
            //创建岛对象
            CrossHsIslandIsland island;
            if (islandId == boxIslandId) {
                island = this.createIsLand(floorId, islandId, boxDataMap);
            } else {
                island = this.createIsLand(floorId, islandId, null);
            }
            islandMap.put(islandId, island);
        }
        return islandMap;
    }

    /**
     * 创建岛
     * @param floorId
     * @param islandId
     * @param boxDataMap 宝箱MAP,无宝箱为null
     * @return
     */
    public synchronized CrossHsIslandIsland createIsLand(int floorId, int islandId, Map<String, HsIslandBoxData> boxDataMap) {
        //生成确认的4格地块坐标
        Map<String, List<HsIslandPosition>> fourLaPositions = this.createFourLaPositions(floorId, islandId, boxDataMap);
        //海神之心进入随机池最小探索进度千分比
        int keyShowRate = this.getConfig().getKeyShowRate();
        //海神之心必现最小探索进度千分比
        int keyMustShowRate = this.getConfig().getKeyMustShowRate();
        //总事件数量
        int allEventNum = this.initAllEventNum(islandId, fourLaPositions.size() / 4);
        //总格子数量
        int allLaNum = allEventNum + fourLaPositions.size() * 3;
        //岛屿数据对象
        HsIslandIslandData islandData = new HsIslandIslandData(
                this.unionData.getActivityId(),
                this.unionData.getGroupId(),
                this.unionData.getUnionId(),
                floorId,
                islandId,
                fourLaPositions,
                keyShowRate,
                keyMustShowRate,
                allEventNum,
                allLaNum
        );
        //未完结事件MAP
        Map<String, HsIslandEventData> eventMap = new ConcurrentHashMap<>();
        //已完结的格子坐标集合
        Set<String> finishPositionSet = new ConcurrentHashSet<>();
        //事件数量MAP,k:事件ID,v:事件数量
        Map<Integer, Integer> eventNumMap = new ConcurrentHashMap<>();
        return new CrossHsIslandIsland(islandData, eventMap, finishPositionSet, eventNumMap);
    }

    /**
     * 初始化总事件数
     * @param islandId
     * @param fourEventNum
     * @return
     */
    private int initAllEventNum(int islandId, int fourEventNum) {
        HsIslandIslandConfig islandConfig = this.getConfig().getIslandConfig(islandId);
        if (islandConfig.getBigPveNum() == fourEventNum) {
            return islandConfig.getAllEventNum();
        }
        //非预期4格数，重新算一下
        int diffNum = islandConfig.getBigPveNum() - fourEventNum;
        int addEventNum = diffNum * 3;
        return islandConfig.getAllEventNum() + addEventNum;
    }

    /**
     * 创建4格事件格子组
     * @param floorId
     * @param islandId
     * @param boxDataMap 宝箱MAP,无宝箱为null
     * @return
     */
    public Map<String, List<HsIslandPosition>> createFourLaPositions(int floorId, int islandId, Map<String, HsIslandBoxData> boxDataMap) {
        HsIslandIslandConfig islandConfig = this.getConfig().getIslandConfig(islandId);
        //获取下宝箱坐标“,”隔开
        Set<String> boxPositionSet = new HashSet<>();
        if (boxDataMap != null) {
            for (String position : boxDataMap.keySet()) {
                String[] positionArr = position.split("_");
                boxPositionSet.add(positionArr[0] + "," + positionArr[1]);
            }
        }

        //取样本，对比方差，取方差最小的样本
        int demoNum = this.getConfig().HSISLAND_MAP_GENERATE_PARAM;//样本数量
        List<HsIslandVarianceData> varianceDataList = new ArrayList<>();
        for (int i = 0; i < demoNum; i++) {
            //获取4格组，并附有方差值
            HsIslandVarianceData varianceData = this.createFourLaVariancePositionData(floorId, islandConfig, boxPositionSet);
            varianceDataList.add(varianceData);
        }
        //排序一下
        varianceDataList.sort(Comparator.comparing(HsIslandVarianceData::getVariance));
        varianceDataList.sort(Comparator.comparing(HsIslandVarianceData::getFourPositionNum).reversed());
        HsIslandVarianceData varianceData = ListHelper.getMedian(varianceDataList);//取中位元素
        Map<String, List<HsIslandPosition>> targetPositionMap = varianceData.getFourPositionMap();

        //格式化map key
        Map<String, List<HsIslandPosition>> resultMap = new ConcurrentHashMap<>();
        for (Map.Entry<String, List<HsIslandPosition>> entry : targetPositionMap.entrySet()) {
            String positionStr = entry.getKey();
            List<HsIslandPosition> positionList = entry.getValue();
            String[] positionArr = positionStr.split(",");
            String x = positionArr[0];
            String y = positionArr[1];
            String key = x + "_" + y;
            resultMap.put(key, positionList);
        }
        return resultMap;
    }

    /**
     * 获取4格组，并附有方差值
     * @param islandConfig
     * @param boxPositionSet
     * @return
     */
    public HsIslandVarianceData createFourLaVariancePositionData(int floorId, HsIslandIslandConfig islandConfig, Set<String> boxPositionSet) {
        //富集度配置MAP
        Map<Integer, Integer> fjdConfigMap = this.getConfig().getFjdConfigMap(floorId);
        //富集度MAP
        Map<String, Integer> fjdMap = new HashMap<>();
        //目标MAP
        Map<String, List<HsIslandPosition>> targetPositionMap = new HashMap<>();
        //创建4格事件坐标
        int maxDgNum = this.getConfig().HSISLAND_PVE_LARGE_MONSTER_GENERATE;//最大递归次数
        islandConfig.createFourLaPositionsNew(targetPositionMap, fjdMap, boxPositionSet, 0, fjdConfigMap, maxDgNum);
        //计算方差
        //①求平均值Avg
        //②格子数N，需排除不可走的、排除出生点、排除宝库格子
        //③方差=[（格子1-Avg）^2+（格子2-Avg）^2+……+（格子N-Avg）^2] / N
        Set<String> latticeSet = new HashSet<>(islandConfig.getMapTypeParamMap().get(HsIslandLatticeTypeEnum.LATTICE_TYPE_ONE.getType()));
        latticeSet.removeAll(boxPositionSet);//排除掉宝箱
        int allFjd = 0;//总富集度
        for (Map.Entry<String, Integer> entry : fjdMap.entrySet()) {
            //排除掉宝箱
            if (boxPositionSet.contains(entry.getKey())) {
                continue;
            }
            allFjd += entry.getValue();
        }
        int aveFjd = allFjd / latticeSet.size();//平均富集度
        int varianceValue1 = 0;
        for (String positionStr : latticeSet) {
            int fjdValue = fjdMap.getOrDefault(positionStr, 0);
            //(格子1-Avg）^2
            varianceValue1 += (int) Math.pow(fjdValue - aveFjd, 2);
        }
        BigDecimal varianceValue2 = BigDecimal.valueOf(varianceValue1).divide(BigDecimal.valueOf(latticeSet.size()), 8, RoundingMode.HALF_UP);
        //返回
        return new HsIslandVarianceData(targetPositionMap, varianceValue2);
    }

    /**
     * 获取海域MAP
     * @return
     */
    public Map<Integer, CrossHsIslandFloor> getFloorMap() {
        return floorMap;
    }

    /**
     * 获取海域
     * @param floorId
     * @return
     */
    public CrossHsIslandFloor getFloor(int floorId) {
        return this.floorMap.get(floorId);
    }

    /**
     * 获取岛屿
     * @param floorId
     * @param islandId
     * @return
     */
    public CrossHsIslandIsland getIsland(int floorId, int islandId) {
        CrossHsIslandFloor floor = this.floorMap.get(floorId);
        if (floor != null) {
            return floor.getIsland(islandId);
        }
        return null;
    }

    /**
     * 获取商会基础信息
     * @return
     */
    public UnionBaseInfo getBaseUnionInfo() {
        UnionActivityGroupUnion groupUnion = Cross2UnionActivityGroupMgr.getUnionData(this.unionData.getActivityId(), this.unionData.getUnionId(), this.unionData.getGroupId());
        if (groupUnion != null) {
            return groupUnion.getUnionBaseInfo();
        }
        return null;
    }

    /**
     * 捐献
     * @param user
     * @param propNum
     * @return
     * @throws BusinessException
     */
    public String donate(CrossHsIslandUser user, int propNum) throws BusinessException {
        //可以双倍捐献次数
        int doubleUsableDonateNum = user.getUserData().getDUsableDonateNum();
        int doubleNum;
        int singleNum ;
        if (doubleUsableDonateNum >= propNum) {
            singleNum = 0;
            doubleNum = propNum;
        } else {
            singleNum = propNum - doubleUsableDonateNum;
            doubleNum = doubleUsableDonateNum;
        }
        //增加的经验
        long onePropExp = this.getConfig().HSISLAND_DONATE_ADD_PROGRESS;
        long addExp = onePropExp * singleNum + onePropExp * doubleNum * 2;
        this.unionData.setExp(this.unionData.getExp() + addExp);
        //获取等级
        int oldLevel = this.unionData.getLevel();
        int level = this.getConfig().getBoatLevel(this.unionData.getExp());
        this.unionData.setLevel(level);
        if (level > oldLevel) {
            //升级，同步一下商会玩家
            for (CrossHsIslandUser member : this.userMap.values()) {
                member.syncUserData();
            }
        }
        //扣除双倍次数
        user.addDUsableDonateNum(-doubleNum);
        //捐献奖励
        Property reward = new Property();
        for (int i = 0; i < singleNum; i++) {
            Property singleReward = PropertyHelper.parseNewStringToProperty(this.getConfig().HSISLAND_DONATE_REWARD);
            reward.addProperty(singleReward);
        }
        for (int i = 0; i < doubleNum; i++) {
            Property singleReward = PropertyHelper.parseNewStringToProperty(this.getConfig().HSISLAND_DONATE_REWARD);
            singleReward.goodCountMultiNum(2);
            reward.addProperty(singleReward);
        }
        String rewardStr = PropertyHelper.parsePropertyToString(reward);
        //玩家记录捐献次数
        user.addDonateNum(propNum);
        //捐献日志
        LogCrossHsIslandDonate log = new LogCrossHsIslandDonate(
                this.unionData.getActivityId(),
                this.unionData.getGroupId(),
                this.unionData.getUnionId(),
                user.getUserData().getUserId(),
                propNum,
                this.unionData.getExp(),
                this.unionData.getLevel(),
                rewardStr
        );
        CrossAutoLogMgr.add(log);
        //返回
        return rewardStr;
    }

    /**
     * 获取战力加成率
     * @return
     */
    public int getPowerAddRate() {
        HsIslandBoatConfig boatConfig =this.getConfig().getBoatConfig(this.unionData.getLevel());
        if (boatConfig == null) {
            return 0;
        }
        return boatConfig.getPowerIncrease();
    }

    /**
     * 最高海域 + 1
     */
    public synchronized void updateMaxFloor() {
        this.unionData.setMaxFloorId(this.unionData.getMaxFloorId() + 1);
        //捐献双倍次数增加
        int dDonateAddNum = this.getConfig().HSISLAND_ADD_DOUBLE_DONATE_NUM;
        for (CrossHsIslandUser member : this.userMap.values()) {
            member.addDUsableDonateNum(dDonateAddNum);
        }
        //商会榜单变更
        this.unionRankChange();
        //跑马灯推送，可前往新海域
        this.syncMarqueeFloorMsg(this.unionData.getMaxFloorId());
        //日志
        LogCrossHsIslandFloorUnlock log = new LogCrossHsIslandFloorUnlock (
                this.unionData.getActivityId(),
                this.unionData.getGroupId(),
                this.unionData.getUnionId(),
                this.unionData.getMaxFloorId()
        );
        CrossAutoLogMgr.add(log);
    }

    /**
     * 获取最高海域的探索进度
     * @return
     */
    public int getMaxFloorExploreProgress() {
        CrossHsIslandFloor maxFloor = this.floorMap.get(this.unionData.getMaxFloorId());
        if (maxFloor == null) {
            return 0;
        }
        return maxFloor.getExploreProgress();
    }

    /**
     * 获取商会总积分
     * @return
     */
    public long getUnionScore() {
        long score = 0;
        for (CrossHsIslandUser user : this.userMap.values()) {
            score += user.getUserData().getScore();
        }
        return score;
    }

    /**
     * 更新商会榜单
     */
    public void unionRankChange() {
        //分组信息
        UnionActivityGroup unionGroupData = Cross2UnionActivityGroupMgr.getGroupData(this.unionData.getActivityId(), this.unionData.getGroupId());
        if (unionGroupData == null) {
            logger.error("海神岛-更新商会榜单-分组信息未找到：{}", this.unionData.getActivityId(), this.unionData.getGroupId());
            return;
        }
        //分组商会信息
        UnionActivityGroupUnion groupUnion = unionGroupData.getGroupUnion(this.unionData.getUnionId());
        if (groupUnion == null) {
            logger.error("海神岛-更新商会榜单-分组商会信息未找到：{}", this.unionData.getActivityId(), this.unionData.getGroupId(), this.unionData.getUnionId());
            return;
        }
        //职位map
        ConcurrentHashMap<Long, Integer> memberMap = new ConcurrentHashMap<>();
        for (UnionActivityGroupUser groupUser : groupUnion.getUserMap().values()) {
            memberMap.put(groupUser.getUserId(), groupUser.getPosition());
        }
        //排行值
        String rankParamValue = this.unionData.getMaxFloorId() + "=" + this.getMaxFloorExploreProgress();
        CrossYRankMgr.unionRankChange(
                this.unionData.getActivityId(),
                this.unionData.getGroupId(),
                String.valueOf(eGamePlayerEventType.HsIslandUnionRank.getValue()),
                unionData.getUnionId(),
                groupUnion.getUnionBaseInfo(),
                memberMap,
                UnionRiseRankArgs.NOTIFY_TYPE_NORMAL,
                DateHelper.getCurrentTime(),
                rankParamValue
        );
        //通知区服,更新成就condition
        this.syncAchievementChange();
    }

    /**
     * 玩家商会成就变更
     */
    public void syncAchievementChange() {
        //通知区服,更新成就condition
        HsIslandProto.HsIslandConditionChangeFromCrossMsg.Builder msg = HsIslandProto.HsIslandConditionChangeFromCrossMsg.newBuilder();
        msg.setActivityId(this.unionData.getActivityId());
        msg.setConditionType(eGamePlayerEventType.HsIslandUnionAchievement.getValue());
        msg.setValue(this.unionData.getMaxFloorId());
        msg.setParam(String.valueOf(this.getMaxFloorExploreProgress()));
        MessageHelper.sendPacketToAll(Protocol.S_HS_ISLAND_CONDITION_CHANGE_FROM_CROSS, msg, this.getUserMap().keySet());
    }

    /**
     * 玩家基金分变更
     */
    public void syncFundScoreChange() {
        long unionScore = this.getUnionScore();
        //通知区服,更新成就condition
        HsIslandProto.HsIslandConditionChangeFromCrossMsg.Builder msg = HsIslandProto.HsIslandConditionChangeFromCrossMsg.newBuilder();
        msg.setActivityId(this.unionData.getActivityId());
        msg.setConditionType(eGamePlayerEventType.CommonActivityFundProgress.getValue());
        msg.setValue(unionScore);
        msg.setParam("");
        MessageHelper.sendPacketToAll(Protocol.S_HS_ISLAND_CONDITION_CHANGE_FROM_CROSS, msg, this.getUserMap().keySet());
    }

    /**
     * 跑马灯-可前往新海域
     * @param newFloorId
     */
    public void syncMarqueeFloorMsg(int newFloorId) {
        HsIslandProto.HsIslandSyncMarqueeMsg.Builder msg = HsIslandProto.HsIslandSyncMarqueeMsg.newBuilder();
        msg.setType(HsIslandMarqueeTypeEnum.MARQUEE_NEW_FLOOR.getType());
        msg.setFloorId(newFloorId);
        MessageHelper.sendPacketToAll(Protocol.U_HS_ISLAND_SYNC_MARQUEE, msg, this.userMap.keySet());
    }

    /**
     * 添加商会日志
     * @param log
     */
    public void addUnionLog(HsIslandUnionLog log) {
        this.unionLogList.add(log);
    }

    /**
     * 获取商会日志
     * @return
     */
    public FixSizeLinkedList<HsIslandUnionLog> getUnionLogList() {
        return unionLogList;
    }
}
